home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume7 / xlock / patch4 next >
Encoding:
Internet Message Format  |  1990-06-13  |  24.8 KB

  1. Path: uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!sun-barr!newstop!sun!cellar.bae.bellcore.com)!aw@garage.bae.bellcore.com
  2. From: aw@garage.bae.bellcore.com (aw@cellar.bae.bellcore.com)
  3. Newsgroups: comp.sources.x
  4. Subject: v07i096: xlock -- lockscreen for X displays, Patch4, Part01/01
  5. Message-ID: <137221@sun.Eng.Sun.COM>
  6. Date: 13 Jun 90 22:54:06 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 801
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: Andrew Wason (aw@cellar.bae.bellcore.com) <aw@garage.bae.bellcore.com>
  12. Posting-number: Volume 7, Issue 96
  13. Archive-name: xlock/patch4
  14.  
  15. [ Moderator's note: There is no Patch-To: line because the source has
  16.     passed through too many hands and revisions since it's original posting
  17.     in Volume 5.  So, let's assume the submitter of this patch is correct
  18.     and call the current version patch level 4.  that is, you should apply
  19.     this patch to version 1.3 of xlock...  Discrepincies should be taken
  20.     up with Andrew Wason, not me.  However, keep me appraised of any
  21.     conclusions for future postings. --dan ]
  22.  
  23. This is an unofficial patch to the contrib xlock program
  24. (patchlevel 1.3 - available from expo.lcs.mit.edu).
  25. I have tried to contact the author, but never received any response.
  26. If this isn't the correct place to send these patches,
  27. please let me know what is.
  28.  
  29. This patch fixes colormap problems xlock has when run under
  30. ICCCM compliant window managers (e.g. R4 twm).
  31. See the file README.patch for more information.
  32.  
  33. The shar file below contains README.patch and xlock.patch.
  34. Typing 'patch < xlock.patch' in the source code directory for
  35. xlock 1.3 will apply the patch.
  36.  
  37. --------------------------------------------------------------------------------
  38. Andrew Wason                                        Bell Communications Research
  39. aw@cellar.bae.bellcore.com                          Piscataway, NJ
  40. bellcore!cellar!aw
  41. --------------------------------------------------------------------------------
  42.  
  43.  
  44. #--------------------------- Cut Here --------------------------
  45. #!/bin/sh
  46. #
  47. # Run this file through sh
  48. #
  49. echo README.patch
  50. sed -e 's/^Z//' > README.patch << 'EOF of README.patch'
  51. Patching:
  52.  
  53.   This is an unofficial patch for version 1.3 of xlock.
  54.   It should only be applied if the file patchlevel.h contains the number 1.3.
  55.   This patch increases the patchlevel to 1.4.
  56.   I did not include a "Prereq:" line in the patch, because patch
  57.   core dumps when I do, so it's up to you to make sure you are patching
  58.   version 1.3.
  59.  
  60. Colormap changes:
  61.  
  62.      Xlock builds it's own colormap which contains colors which make the
  63.   qix, hop and life modes look appealing (e.g. the stick color in qix moves
  64.   through different hues as it moves around the screen).  Xlock version 1.3
  65.   used XInstallColormap()/XUninstallColormap() to forcibly install/uninstall
  66.   this colormap. This violates ICCCM standards and does not work with
  67.   ICCCM compliant window managers (e.g. R4 twm). An ICCCM compliant window
  68.   manager will print an error message and refuse to install the colormap.
  69.   This makes xlock's colors look like garbage.
  70.  
  71.      An ICCCM compliant client should use XSetWindowColormap() and let the
  72.   window manager install the colormap for it.  This will not work for xlock
  73.   because the xlock window is override_redirect and so the window manager
  74.   doesn't know it exists and never installs the colormap.
  75.  
  76.      To solve this problem, this unofficial version of xlock uses XAllocColor()
  77.   to attempt to allocate the colors it needs out of the default colormap.
  78.   How many colors xlock is able to allocate depends on what other clients
  79.   are running. If the root window contains a colorful image, for example,
  80.   then xlock will not get as many colors. Use the -v option to see how
  81.   many colors xlock is able to allocate. In most cases, xlock can allocate
  82.   enough colors to look decent.
  83.  
  84.       There is a new -install option to xlock which makes it behave the
  85.   way the 1.3 version did (i.e. use XInstallColormap()/XUninstallColormap()).
  86.   This is useful for non-ICCCM compliant window managers.
  87.  
  88.  
  89. Popup windows:
  90.  
  91.      This patch also fixes a problem xlock has with popup windows.
  92.   Xlock does not allow any new clients to connect to the locked display,
  93.   but if a client is already connected but unmapped, and this client maps
  94.   itself after the screen has been locked, then this client's window will
  95.   pop up on top of the xlock window and potentially burn-in the screen.
  96.   An example of this is the xconsole program which is unmapped until it gets
  97.   a console message. It then maps itself on top of the xlock window.
  98.  
  99.      This patched version of xlock raises the xlock window every 'timeout'
  100.   seconds. So any windows which have popped up will be covered again.
  101.  
  102.  
  103. Andrew Wason
  104. Bellcore
  105. aw@cellar.bae.bellcore.com
  106. EOF of README.patch
  107. echo "      55     418    2626 README.patch"
  108. wc README.patch
  109.  
  110. echo xlock.patch
  111. sed -e 's/^Z//' > xlock.patch << 'EOF of xlock.patch'
  112. Index: patchlevel.h
  113. diff -c xlock.orig/patchlevel.h xlock.new/patchlevel.h
  114. *** xlock.orig/patchlevel.h    Thu Jun  7 09:49:42 1990
  115. --- xlock.new/patchlevel.h    Wed Jun 13 16:03:40 1990
  116. ***************
  117. *** 1 ****
  118. ! 1.3
  119. --- 1 ----
  120. ! 1.4
  121. diff -c xlock.orig/HSBmap.c xlock.new/HSBmap.c
  122. *** xlock.orig/HSBmap.c    Thu Jun  7 09:49:45 1990
  123. --- xlock.new/HSBmap.c    Fri May 18 19:26:35 1990
  124. ***************
  125. *** 110,118 ****
  126.       r = red;
  127.       g = green;
  128.       b = blue;
  129. !     dh = (h2 - h1) / 255.0;
  130. !     ds = (s2 - s1) / 255.0;
  131. !     db = (b2 - b1) / 255.0;
  132.       for (i = start; i <= end; i++) {
  133.       hsb2rgb(h1, s1, b1, r++, g++, b++);
  134.       h1 += dh;
  135. --- 110,118 ----
  136.       r = red;
  137.       g = green;
  138.       b = blue;
  139. !     dh = (h2 - h1) / (double) (end - start);
  140. !     ds = (s2 - s1) / (double) (end - start);
  141. !     db = (b2 - b1) / (double) (end - start);
  142.       for (i = start; i <= end; i++) {
  143.       hsb2rgb(h1, s1, b1, r++, g++, b++);
  144.       h1 += dh;
  145. diff -c xlock.orig/README xlock.new/README
  146. *** xlock.orig/README    Thu Jun  7 09:49:41 1990
  147. --- xlock.new/README    Wed Jun  6 17:05:36 1990
  148. ***************
  149. *** 1,3 ****
  150. --- 1,13 ----
  151. + This is an unofficially patched version of xlock version 1.3
  152. + CHANGES:
  153. +    o use the default colormap instead of forcibly installing a colormap
  154. +    o forcibly install the colormap if the -install option is used
  155. +    o raise the xlock window every 'timeout' seconds (to cover any windows
  156. +      which have popped up)
  157. + ----------------- version 1.3 README ------------------------------------
  158.   
  159.   This is the latest version of xlock (sccs version 22.7) patchlevel = 1.3
  160.   
  161. diff -c xlock.orig/XCrDynCmap.c xlock.new/XCrDynCmap.c
  162. *** xlock.orig/XCrDynCmap.c    Thu Jun  7 09:49:45 1990
  163. --- xlock.new/XCrDynCmap.c    Fri May 18 19:01:46 1990
  164. ***************
  165. *** 29,85 ****
  166.   #include <X11/Xutil.h>
  167.   
  168.   Status
  169. ! XCreateDynamicColormap(dsp, screen, cmap, visual, colors,
  170. !                count, red, green, blue)
  171. !     Display    *dsp;
  172. !     int        screen;
  173. !     Colormap   *cmap;
  174. !     Visual    **visual;
  175. !     XColor     *colors;
  176. !     int        count;
  177. !     u_char     *red,
  178. !            *green,
  179. !            *blue;
  180.   {
  181.       XVisualInfo vinfo;
  182. -     int        pixels[256];
  183.       int        i,
  184. -         ncolors,
  185.           planes;
  186. !     unsigned long pmasks;
  187. !     Status    allocReturn;
  188.   
  189.       planes = DisplayPlanes(dsp, screen);
  190.       if (XMatchVisualInfo(dsp, screen, planes, PseudoColor, &vinfo)) {
  191.   
  192.       *visual = vinfo.visual;
  193. !     *cmap = XCreateColormap(dsp, RootWindow(dsp, screen),
  194. !                 *visual, AllocNone);
  195. !     ncolors = vinfo.colormap_size;
  196.   
  197. !     if (count > ncolors)
  198. !         return BadValue;
  199.   
  200. !     allocReturn = XAllocColorCells(dsp, *cmap,
  201. !                        False, &pmasks, 0,
  202. !                        pixels, count);
  203.   
  204. ! /*    This should return Success, but it doesn't... Xlib bug?
  205. !  *    (I'll ignore the return value for now...)
  206. !  */
  207. ! #ifdef NOTDEF
  208. !     if (allocReturn != Success)
  209. !         return allocReturn;
  210. ! #endif                /* NOTDEF */
  211.   
  212. !     for (i = 0; i < count; i++) {
  213. !         colors[i].pixel = pixels[i];
  214. !         colors[i].red = *red++ << 8;
  215. !         colors[i].green = *green++ << 8;
  216. !         colors[i].blue = *blue++ << 8;
  217. !         colors[i].flags = DoRed | DoGreen | DoBlue;
  218.       }
  219. !     XStoreColors(dsp, *cmap, colors, count);
  220.       return Success;
  221.       } else
  222.       return BadMatch;
  223. --- 29,86 ----
  224.   #include <X11/Xutil.h>
  225.   
  226.   Status
  227. ! XCreateDynamicColormap(dsp, screen, cmap, install, visual, red, green, blue,
  228. !         pixels, npixels)
  229. !     Display        *dsp;
  230. !     int            screen;
  231. !     Colormap        *cmap;
  232. !     int            install;
  233. !     Visual        **visual;
  234. !     u_char        *red,
  235. !             *green,
  236. !             *blue;
  237. !     unsigned long    pixels[256];    /* returned array of useable pixels 
  238. !                        in default colormap */
  239. !     int            *npixels;
  240.   {
  241.       XVisualInfo vinfo;
  242.       int        i,
  243.           planes;
  244. !     XColor    xcolors[256];
  245. !     char    flags;
  246.   
  247.       planes = DisplayPlanes(dsp, screen);
  248.       if (XMatchVisualInfo(dsp, screen, planes, PseudoColor, &vinfo)) {
  249.   
  250.       *visual = vinfo.visual;
  251. !     if (install)
  252. !         *cmap = XCreateColormap(dsp, RootWindow(dsp, screen),
  253. !                 *visual, AllocAll);
  254. !     else
  255. !         *cmap = DefaultColormap(dsp, screen);
  256.   
  257. !     *npixels = 0;
  258. !     flags = DoRed | DoGreen | DoBlue;
  259. !     for (i = 0; i < DisplayCells(dsp, screen); i++) {
  260. !         xcolors[i].red = *red++ << 8;
  261. !         xcolors[i].green = *green++ << 8;
  262. !         xcolors[i].blue = *blue++ << 8;
  263. !         xcolors[i].flags = flags;
  264.   
  265. !         if (install)
  266. !         xcolors[i].pixel = i;
  267.   
  268. !         /* if we successfuly alloc a color, save the pixel,
  269. !            if we fail then we are out of colormap space */
  270. !         else
  271. !         if (!XAllocColor(dsp, *cmap, &xcolors[i]))
  272. !             break;
  273.   
  274. !         pixels[i] = xcolors[i].pixel;
  275. !         (*npixels)++;
  276.       }
  277. !     if (install)
  278. !         XStoreColors(dsp, *cmap, xcolors, DisplayCells(dsp, screen));
  279.       return Success;
  280.       } else
  281.       return BadMatch;
  282. diff -c xlock.orig/XCrHsbCmap.c xlock.new/XCrHsbCmap.c
  283. *** xlock.orig/XCrHsbCmap.c    Thu Jun  7 09:49:45 1990
  284. --- xlock.new/XCrHsbCmap.c    Fri May 18 19:26:10 1990
  285. ***************
  286. *** 27,47 ****
  287.   #include <X11/Xos.h>
  288.   #include <X11/Xlib.h>
  289.   
  290. ! extern void HSBmap();
  291.   
  292.   Status
  293. ! XCreateHSBColormap(dsp, screen, cmap, count, h1, s1, b1, h2, s2, b2, bw)
  294. !     Display    *dsp;
  295. !     int         screen;
  296. !     Colormap   *cmap;        /* colormap return value */
  297. !     int         count;        /* number of entrys to use */
  298. !     double      h1,        /* starting hue */
  299. !                 s1,        /* starting saturation */
  300. !                 b1,        /* starting brightness */
  301. !                 h2,        /* ending hue */
  302. !                 s2,        /* ending saturation */
  303. !                 b2;        /* ending brightness */
  304. !     int         bw;        /* Boolean: True = save black and white */
  305.   {
  306.       u_char      red[256];
  307.       u_char      green[256];
  308. --- 27,50 ----
  309.   #include <X11/Xos.h>
  310.   #include <X11/Xlib.h>
  311.   
  312. ! extern void HSBramp();
  313.   
  314.   Status
  315. ! XCreateHSBColormap(dsp, screen, cmap, install, h1, s1, b1, h2, s2, b2, bw,
  316. !             pixels, npixels)
  317. !     Display      *dsp;
  318. !     int           screen;
  319. !     Colormap     *cmap;        /* if install, colormap return value */
  320. !     int           install;    /* true if we should install a colormap */
  321. !     double        h1,        /* starting hue */
  322. !                   s1,        /* starting saturation */
  323. !                   b1,        /* starting brightness */
  324. !                   h2,        /* ending hue */
  325. !                   s2,        /* ending saturation */
  326. !                   b2;        /* ending brightness */
  327. !     int           bw;        /* Boolean: True = save black and white */
  328. !     unsigned long pixels[256];    /* return array of useable pixels */
  329. !     int          *npixels;
  330.   {
  331.       u_char      red[256];
  332.       u_char      green[256];
  333. ***************
  334. *** 49,61 ****
  335.       unsigned long pixel;
  336.       Status      status;
  337.       Visual     *visual;
  338. -     XColor      xcolors[256];
  339.   
  340. !     if (count > 256)
  341. !     return BadValue;
  342.   
  343. -     HSBramp(h1, s1, b1, h2, s2, b2, 0, count - 1, red, green, blue);
  344.       if (bw) {
  345.       pixel = WhitePixel(dsp, screen);
  346.       red[pixel] = green[pixel] = blue[pixel] = 0xff;
  347. --- 52,61 ----
  348.       unsigned long pixel;
  349.       Status      status;
  350.       Visual     *visual;
  351.   
  352. !     /* create 3 256 element arrays of rgb values */
  353. !     HSBramp(h1, s1, b1, h2, s2, b2, 0, DisplayCells(dsp, screen) - 1, red, green, blue);
  354.   
  355.       if (bw) {
  356.       pixel = WhitePixel(dsp, screen);
  357.       red[pixel] = green[pixel] = blue[pixel] = 0xff;
  358. ***************
  359. *** 63,70 ****
  360.       pixel = BlackPixel(dsp, screen);
  361.       red[pixel] = green[pixel] = blue[pixel] = 0;
  362.       }
  363. !     status = XCreateDynamicColormap(dsp, screen, cmap, &visual, xcolors,
  364. !                     count, red, green, blue);
  365.   
  366.       return status;
  367.   }
  368. --- 63,70 ----
  369.       pixel = BlackPixel(dsp, screen);
  370.       red[pixel] = green[pixel] = blue[pixel] = 0;
  371.       }
  372. !     status = XCreateDynamicColormap(dsp, screen, cmap, install, &visual,
  373. !                     red, green, blue, pixels, npixels);
  374.   
  375.       return status;
  376.   }
  377. diff -c xlock.orig/hopalong.c xlock.new/hopalong.c
  378. *** xlock.orig/hopalong.c    Thu Jun  7 09:49:43 1990
  379. --- xlock.new/hopalong.c    Fri May 18 19:01:46 1990
  380. ***************
  381. *** 29,34 ****
  382. --- 29,35 ----
  383.    *               Mountain View, CA  94043
  384.    *
  385.    * Revision History:
  386. +  * 09-May-90: Use Pixels[] array to index into default colormap.
  387.    * 15-Dec-89: Fix for proper skipping of {White,Black}Pixel() in colors.
  388.    * 08-Oct-89: Fixed long standing typo bug in RandomInitHop();
  389.    *          Fixed bug in memory allocation in inithop();
  390. ***************
  391. *** 44,49 ****
  392. --- 45,53 ----
  393.   #include <X11/Xlib.h>
  394.   #include <X11/Xutil.h>
  395.   
  396. + extern unsigned long Pixels[];
  397. + extern int NPixels;
  398.   static int  centerx,
  399.           centery;        /* center of the screen */
  400.   static double a,
  401. ***************
  402. *** 152,162 ****
  403.       register XPoint *xp = pointBuffer;
  404.   
  405.       if (color) {
  406. !     XSetForeground(Dsp, Gc, pix++);
  407. !     while (pix >= DisplayCells(Dsp, DefaultScreen(Dsp)) ||
  408.           pix == WhitePixel(Dsp, DefaultScreen(Dsp)) ||
  409.           pix == BlackPixel(Dsp, DefaultScreen(Dsp))) {
  410. !         if (pix >= DisplayCells(Dsp, DefaultScreen(Dsp)))
  411.           pix = 0;
  412.           else
  413.           pix++;
  414. --- 156,166 ----
  415.       register XPoint *xp = pointBuffer;
  416.   
  417.       if (color) {
  418. !     XSetForeground(Dsp, Gc, Pixels[pix++]);
  419. !     while (pix >= NPixels ||
  420.           pix == WhitePixel(Dsp, DefaultScreen(Dsp)) ||
  421.           pix == BlackPixel(Dsp, DefaultScreen(Dsp))) {
  422. !         if (pix >= NPixels)
  423.           pix = 0;
  424.           else
  425.           pix++;
  426. diff -c xlock.orig/life.c xlock.new/life.c
  427. *** xlock.orig/life.c    Thu Jun  7 09:49:44 1990
  428. --- xlock.new/life.c    Fri May 18 19:01:46 1990
  429. ***************
  430. *** 30,35 ****
  431. --- 30,36 ----
  432.    *               Mountain View, CA  94043
  433.    *
  434.    * Revision History:
  435. +  * 09-May-90: Use Pixels[] array to index into default colormap.
  436.    * 07-Feb-90: remove bogus semi-colon after #include line.
  437.    * 15-Dec-89: Fix for proper skipping of {White,Black}Pixel() in colors.
  438.    * 08-Oct-89: Moved seconds() to an extern.
  439. ***************
  440. *** 41,46 ****
  441. --- 42,50 ----
  442.   #include <X11/Xutil.h>
  443.   #include "lifeicon.bit"
  444.   
  445. + extern unsigned long Pixels[];
  446. + extern int NPixels;
  447.   static XImage logo = {
  448.       0, 0,            /* width, height */
  449.       0, XYBitmap, 0,        /* xoffset, format, data */
  450. ***************
  451. *** 323,337 ****
  452.       register unsigned char *ageptr = agebuf + (loc - buffer);
  453.       register unsigned char age = *ageptr;
  454.   
  455. !     while (age >= DisplayCells(Dsp, DefaultScreen(Dsp)) ||
  456.           age == WhitePixel(Dsp, DefaultScreen(Dsp)) ||
  457.           age == BlackPixel(Dsp, DefaultScreen(Dsp))) {
  458. !         if (age >= DisplayCells(Dsp, DefaultScreen(Dsp)))
  459.           age = 0;
  460.           else
  461.           age++;
  462.       }
  463. !     XSetForeground(Dsp, Gc, age);
  464.       *ageptr = age + 1;
  465.       }
  466.       if (pixels)
  467. --- 327,341 ----
  468.       register unsigned char *ageptr = agebuf + (loc - buffer);
  469.       register unsigned char age = *ageptr;
  470.   
  471. !     while (age >= NPixels ||
  472.           age == WhitePixel(Dsp, DefaultScreen(Dsp)) ||
  473.           age == BlackPixel(Dsp, DefaultScreen(Dsp))) {
  474. !         if (age >= NPixels)
  475.           age = 0;
  476.           else
  477.           age++;
  478.       }
  479. !     XSetForeground(Dsp, Gc, Pixels[age]);
  480.       *ageptr = age + 1;
  481.       }
  482.       if (pixels)
  483. diff -c xlock.orig/qix.c xlock.new/qix.c
  484. *** xlock.orig/qix.c    Thu Jun  7 09:49:44 1990
  485. --- xlock.new/qix.c    Fri May 18 19:01:46 1990
  486. ***************
  487. *** 29,34 ****
  488. --- 29,35 ----
  489.    *               Mountain View, CA  94043
  490.    *
  491.    * Revision History:
  492. +  * 09-May-90: Use Pixels[] array to index into default colormap.
  493.    * 15-Dec-89: Fix for proper skipping of {White,Black}Pixel() in colors.
  494.    * 08-Oct-89: Fixed bug in memory allocation in initqix().
  495.    *          Moved seconds() to an extern.
  496. ***************
  497. *** 41,46 ****
  498. --- 42,50 ----
  499.   #include <X11/Xlib.h>
  500.   #include <X11/Xutil.h>
  501.   
  502. + extern unsigned long Pixels[];
  503. + extern int NPixels;
  504.   static Display *Dsp;
  505.   static Window Win;
  506.   static GC   Gc,
  507. ***************
  508. *** 156,166 ****
  509.       check_bounds_x(x2, &dx2);
  510.       check_bounds_y(y2, &dy2);
  511.       if (color) {
  512. !         XSetForeground(Dsp, Gc, pix++);
  513. !         while (pix >= DisplayCells(Dsp, DefaultScreen(Dsp)) ||
  514.               pix == WhitePixel(Dsp, DefaultScreen(Dsp)) ||
  515.               pix == BlackPixel(Dsp, DefaultScreen(Dsp))) {
  516. !         if (pix >= DisplayCells(Dsp, DefaultScreen(Dsp)))
  517.               pix = 0;
  518.           else
  519.               pix++;
  520. --- 160,170 ----
  521.       check_bounds_x(x2, &dx2);
  522.       check_bounds_y(y2, &dy2);
  523.       if (color) {
  524. !         XSetForeground(Dsp, Gc, Pixels[pix++]);
  525. !         while (pix >= NPixels ||
  526.               pix == WhitePixel(Dsp, DefaultScreen(Dsp)) ||
  527.               pix == BlackPixel(Dsp, DefaultScreen(Dsp))) {
  528. !         if (pix >= NPixels)
  529.               pix = 0;
  530.           else
  531.               pix++;
  532. diff -c xlock.orig/xlock.c xlock.new/xlock.c
  533. *** xlock.orig/xlock.c    Thu Jun  7 09:49:43 1990
  534. --- xlock.new/xlock.c    Fri May 18 19:01:46 1990
  535. ***************
  536. *** 29,34 ****
  537. --- 29,40 ----
  538.    *               Mountain View, CA  94043
  539.    *
  540.    * Revision History:
  541. +  * 18-May-90: Raise window on reinit() - takes care of dialog boxes that pop
  542. +  *              up on top of xlock window.
  543. +  * 09-May-90: xlock will only install a colormap if the -install option is used
  544. +  *              The default action is to attempt allocate all colorcells out
  545. +  *              of the default colormap. This will satisfy ICCCM compliant
  546. +  *              window managers.
  547.    * 18-Feb-90: added SunOS3.5 fix.
  548.    *          changed -mono -> -color, and -saver -> -lock.
  549.    *          allow non-locking screensavers to display on remote machine.
  550. ***************
  551. *** 148,153 ****
  552. --- 154,162 ----
  553.   void        (*callback) () = NULL;
  554.   void        (*init) () = NULL;
  555.   
  556. + unsigned long Pixels[256];    /* array of colormap indices for HSB colors */
  557. + int           NPixels;
  558.   char       *pname;        /* argv[0] */
  559.   Display       *dsp = NULL;        /* server display connection */
  560.   int        screen;        /* current screen */
  561. ***************
  562. *** 170,175 ****
  563. --- 179,185 ----
  564.   char       *fontname = NULL;    /* the font used in the password screen */
  565.   int        lockprocindex;    /* which proc in LockProcs is selected */
  566.   Bool        color = -1;        /* color or mono */
  567. + Bool        install = -1;    /* install colormap, or use default */
  568.   Bool        lock = -1;        /* locked or just saver mode */
  569.   Bool        allowroot = -1;    /* allow root password to unlock? */
  570.   Bool        xhost = -1;        /* whether or not to lock out all hosts */
  571. ***************
  572. *** 193,198 ****
  573. --- 203,209 ----
  574.   #define DEFAULT_FONTNAME    "-*-lucida-medium-r-normal-sans-24-*-*-*-*-*-*-*"
  575.   #define BACKUP_FONTNAME        "fixed"
  576.   #define DEFAULT_COLOR        True
  577. + #define DEFAULT_INSTALL        False
  578.   #define DEFAULT_LOCK        True
  579.   #define DEFAULT_ALLOWROOT    False
  580.   #define DEFAULT_XHOST        True
  581. ***************
  582. *** 343,349 ****
  583.       if (screensaver)
  584.       XSetScreenSaver(dsp, timeout, interval, blanking, exposures);
  585.       XDestroyWindow(dsp, w);
  586. !     if (color)
  587.       XUninstallColormap(dsp, cmap);
  588.       XFlush(dsp);
  589.       XCloseDisplay(dsp);
  590. --- 354,360 ----
  591.       if (screensaver)
  592.       XSetScreenSaver(dsp, timeout, interval, blanking, exposures);
  593.       XDestroyWindow(dsp, w);
  594. !     if (color && install)
  595.       XUninstallColormap(dsp, cmap);
  596.       XFlush(dsp);
  597.       XCloseDisplay(dsp);
  598. ***************
  599. *** 547,554 ****
  600.       do {
  601.       while (!XPending(dsp)) {
  602.           callback();
  603. !         if (reinit())
  604.           init(dsp, w, gc, color, inittime, count);
  605.       }
  606.       XNextEvent(dsp, &event);
  607.       } while (event.type != ButtonPress && event.type != KeyPress);
  608. --- 558,567 ----
  609.       do {
  610.       while (!XPending(dsp)) {
  611.           callback();
  612. !         if (reinit()) {
  613.           init(dsp, w, gc, color, inittime, count);
  614. +             XRaiseWindow(dsp, w);
  615. +         }
  616.       }
  617.       XNextEvent(dsp, &event);
  618.       } while (event.type != ButtonPress && event.type != KeyPress);
  619. ***************
  620. *** 573,581 ****
  621.       for (i = 1; i < NUMPROCS; i++)
  622.       fprintf(stderr, " | %s", LockProcs[i].cmdline_arg);
  623.       fprintf(stderr, "]\n");
  624. !     fprintf(stderr, "\t%s\n\t%s\n",
  625.           "[-time n] [-count n] [-nice n] [-font f]",
  626. !     "[-color] [-lock] [-root] [-xhost] [-screensaver] [-echokeys] [-v]");
  627.       exit(1);
  628.   }
  629.   
  630. --- 586,595 ----
  631.       for (i = 1; i < NUMPROCS; i++)
  632.       fprintf(stderr, " | %s", LockProcs[i].cmdline_arg);
  633.       fprintf(stderr, "]\n");
  634. !     fprintf(stderr, "\t%s\n\t%s\n\t%s\n",
  635.           "[-time n] [-count n] [-nice n] [-font f]",
  636. !         "[-color] [-install] [-lock] [-root] [-xhost] [-screensaver]",
  637. !         "[-echokeys] [-v]");
  638.       exit(1);
  639.   }
  640.   
  641. ***************
  642. *** 593,598 ****
  643. --- 607,614 ----
  644.       }
  645.       }
  646.       usage("Unknown Mode.");
  647. +     /* NOTREACHED */
  648.   }
  649.   
  650.   
  651. ***************
  652. *** 648,653 ****
  653. --- 664,671 ----
  654.           display = argv[i];
  655.       } else if (!strncmp("-color", s, n)) {
  656.           color = !DEFAULT_COLOR;
  657. +     } else if (!strncmp("-install", s, n)) {
  658. +         install = !DEFAULT_INSTALL;
  659.       } else if (!strncmp("-lock", s, n)) {
  660.           lock = !DEFAULT_LOCK;
  661.       } else if (!strncmp("-root", s, n)) {
  662. ***************
  663. *** 760,775 ****
  664. --- 778,805 ----
  665.       if (font == NULL)
  666.           error("%s: can't even find %s!!!\n", BACKUP_FONTNAME);
  667.       }
  668. +     if (install == -1)
  669. +     install = XGetBoolDefault("install", DEFAULT_INSTALL);
  670.       screen = DefaultScreen(dsp);
  671.       if (color)
  672.       color = (DisplayCells(dsp, screen) > 2);
  673.       root = RootWindow(dsp, screen);
  674.   
  675. +     if (color) {
  676. +     if (XCreateHSBColormap(dsp, screen, &cmap, install,
  677. +         0.0, 1.0, 1.0, 1.0, 1.0, 1.0, True,
  678. +         Pixels, &NPixels) != Success)
  679. +         error("%s: couldn't match PseudoColor visual.");
  680. +     } else
  681. +     cmap = DefaultColormap(dsp, screen);
  682.       if (verbose) {
  683.       fprintf(stderr, "display = %s\n", display);
  684.       fprintf(stderr, "font = %s\n", fontname);
  685.       fprintf(stderr, "mode = %s\n", LockProcs[lockprocindex].cmdline_arg);
  686.       fprintf(stderr, "color = %s\n", sbool(color));
  687. +     fprintf(stderr, "#colors = %d\n", NPixels);
  688. +     fprintf(stderr, "install = %s\n", sbool(install));
  689.       fprintf(stderr, "lock = %s\n", sbool(lock));
  690.       fprintf(stderr, "root = %s\n", sbool(allowroot));
  691.       fprintf(stderr, "xhost = %s\n", sbool(xhost));
  692. ***************
  693. *** 779,790 ****
  694.       fprintf(stderr, "count = %d\n", count);
  695.       fprintf(stderr, "nice = %d\n", nicelevel);
  696.       }
  697. -     if (color) {
  698. -     if (XCreateHSBColormap(dsp, screen, &cmap, DisplayCells(dsp, screen),
  699. -                    0.0, 1.0, 1.0, 1.0, 1.0, 1.0, True) != Success)
  700. -         error("%s: couldn't create colormap.");
  701. -     } else
  702. -     cmap = DefaultColormap(dsp, screen);
  703.   
  704.       black.pixel = BlackPixel(dsp, screen);
  705.       XQueryColor(dsp, cmap, &black);
  706. --- 809,814 ----
  707. ***************
  708. *** 803,815 ****
  709. --- 827,849 ----
  710.       xswa.background_pixel = black.pixel;
  711.       xswa.event_mask = KeyPressMask | ButtonPressMask;
  712.   
  713. + #ifdef SABER
  714.       w = XCreateWindow(dsp, root,
  715.                 0, 0,
  716. +               500,
  717. +               500,
  718. +               0, CopyFromParent, InputOutput, CopyFromParent,
  719. +               CWCursor | CWOverrideRedirect |
  720. +               CWBackPixel | CWEventMask, &xswa);
  721. + #else
  722. +     w = XCreateWindow(dsp, root,
  723. +               0, 0,
  724.                 DisplayWidth(dsp, screen),
  725.                 DisplayHeight(dsp, screen),
  726.                 0, CopyFromParent, InputOutput, CopyFromParent,
  727.                 CWCursor | CWOverrideRedirect |
  728.                 CWBackPixel | CWEventMask, &xswa);
  729. + #endif
  730.   
  731.       xswa.cursor = XCreateFontCursor(dsp, XC_target);
  732.       xswa.background_pixel = white.pixel;
  733. ***************
  734. *** 837,843 ****
  735. --- 871,879 ----
  736.       XGetScreenSaver(dsp, &timeout, &interval, &blanking, &exposures);
  737.       XSetScreenSaver(dsp, 0, 0, 0, 0);    /* disable screen saver */
  738.       }
  739. + #ifndef SABER
  740.       GrabKeyboardAndMouse();
  741. + #endif
  742.   
  743.       if (lock) {
  744.       if (xhost)
  745. ***************
  746. *** 847,853 ****
  747.       nice(nicelevel);
  748.       srandom(getpid());
  749.   
  750. !     if (color)
  751.       XInstallColormap(dsp, cmap);
  752.   
  753.       if (lock)
  754. --- 883,889 ----
  755.       nice(nicelevel);
  756.       srandom(getpid());
  757.   
  758. !     if (color && install)
  759.       XInstallColormap(dsp, cmap);
  760.   
  761.       if (lock)
  762. diff -c xlock.orig/xlock.man xlock.new/xlock.man
  763. *** xlock.orig/xlock.man    Thu Jun  7 09:49:42 1990
  764. --- xlock.new/xlock.man    Wed Jun  6 16:45:38 1990
  765. ***************
  766. *** 44,49 ****
  767. --- 44,52 ----
  768.   [
  769.   .B \-v
  770.   ]
  771. + [
  772. + .B \-install
  773. + ]
  774.   
  775.   .SH DESCRIPTION
  776.   .B xlock
  777. ***************
  778. *** 179,184 ****
  779. --- 182,194 ----
  780.   .TP 5
  781.   .B \-v
  782.   Verbose mode, tells what options it is going to use.
  783. + .TP 5
  784. + .B \-install
  785. + Forcibly install the colormap.
  786. + This violates ICCCM standards and will not work with ICCCM
  787. + compliant window managers.
  788. + This option exists for backward compatibility with older
  789. + versions of xlock.
  790.   
  791.   .SH BUGS
  792.   "kill -KILL
  793. EOF of xlock.patch
  794. echo "     691    2686   20177 xlock.patch"
  795. wc xlock.patch
  796.  
  797.  
  798. dan
  799. ----------------------------------------------------
  800. O'Reilly && Associates   argv@sun.com / argv@ora.com
  801. Opinions expressed reflect those of the author only.
  802.